load('../../src/chrome/content/folderplus-conversation.js');

// from http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-javascript                                           
Array.prototype.compare = function (array) {
    // if the other array is a falsy value, return
    if (!array)
        return false;

    // compare lengths - can save a lot of time
    if (this.length != array.length)
        return false;

    for (var i = 0, l=this.length; i < l; i++) {
        // Check if we have nested arrays
        if (this[i] instanceof Array && array[i] instanceof Array) {
            // recurse into the nested arrays
            if (!this[i].compare(array[i]))
                return false;
        }
        else if (this[i] != array[i]) {
            // Warning - two different object instances will never be equal: {x:20} != {x:20}
            return false;
        }
    }
    return true;
}

function run_test() {
  folderplus.conv._blackListURIs = ["mailbox://nobody@Local%20Folders/Archives",
                                    "mailbox://nobody@Local%20Folders/Archives/test",
                                    "mailbox://nobody@Local%20Folders/ArchivesXXXX/test",
                                    "mailbox://nobody@Local%20Folders/test"];
                                    
  var result = folderplus.conv._updateBlackListWithURI("mailbox://nobody@Local%20Folders/Archives","mailbox://nobody@Local%20Folders/TOTO");
  
  var expected = ["mailbox://nobody@Local%20Folders/TOTO",
                  "mailbox://nobody@Local%20Folders/TOTO/test",
                  "mailbox://nobody@Local%20Folders/ArchivesXXXX/test",
                  "mailbox://nobody@Local%20Folders/test"];
  
  do_check_true(folderplus.conv._blackListURIs.compare(expected));
  do_check_true(result);
}
